package com.cupster.base_super_resource.gesturedetector;

import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.SimpleOnGestureListener;
import android.view.MotionEvent;
import android.view.ScaleGestureDetector;
import android.widget.TextView;

import com.cupster.base_super_resource.R;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class GesTureActivity extends AppCompatActivity   {

    GestureDetector mDetector;
    TextView mTvGesture;
    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_gesture_detector);
        mTvGesture = findViewById(R.id.tv_words);

        mDetector = new GestureDetector(this ,mSimpleOnGestureListener);
        mDetector.setOnDoubleTapListener(mSimpleOnGestureListener);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
            mDetector.setContextClickListener(mSimpleOnGestureListener);
        }
        mDetector.setIsLongpressEnabled(true);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        return mDetector.onTouchEvent(event);
    }

    SimpleOnGestureListener mSimpleOnGestureListener = new SimpleOnGestureListener(){
        @Override
        public boolean onDown(MotionEvent e) {
            Log.e("GestureDetector" ,"onDown");
            Log.e("GestureDetector" ,"=========================================");
            return super.onDown(e);
        }

        @Override
        public void onShowPress(MotionEvent e) {
            Log.e("GestureDetector" ,"onShowPress");
            Log.e("GestureDetector" ,"=========================================");
            super.onShowPress(e);
        }

        @Override
        public void onLongPress(MotionEvent e) {
            Log.e("GestureDetector" ,"onLongPress");
            Log.e("GestureDetector" ,"=========================================");
            super.onLongPress(e);
        }

        @Override
        public boolean onSingleTapUp(MotionEvent e) {

            Log.e("GestureDetector" ,"onSingleTapUp");
            Log.e("GestureDetector" ,"=========================================");
            return super.onSingleTapUp(e);
        }

        @Override
        public boolean onSingleTapConfirmed(MotionEvent e) {
            Log.e("GestureDetector" ,"onSingleTapConfirmed");
            Log.e("GestureDetector" ,"=========================================");
            return super.onSingleTapConfirmed(e);
        }

        @Override
        public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
            Log.e("GestureDetector" ,"onScroll");
            Log.e("GestureDetector" ,"=========================================");
            return super.onScroll(e1, e2, distanceX, distanceY);
        }

        @Override
        public boolean onDoubleTap(MotionEvent e) {
            Log.e("GestureDetector" ,"onDoubleTap");
            Log.e("GestureDetector" ,"=========================================");
            return super.onDoubleTap(e);
        }

        @Override
        public boolean onDoubleTapEvent(MotionEvent e) {
            Log.e("GestureDetector" ,"onDoubleTapEvent");
            Log.e("GestureDetector" ,"=========================================");
            return super.onDoubleTapEvent(e);
        }

        @Override
        public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) {
            Log.e("GestureDetector" ,"onFling");
            Log.e("GestureDetector" ,"=========================================");
            return super.onFling(e1, e2, velocityX, velocityY);
        }
    };


}
